package com.example.admin.goodnews.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.admin.goodnews.R;
import com.example.admin.goodnews.entity.WeekendSalesDataEntity;

/**
 * 周末票房适配器
 * Created by admin on 2016/10/13.
 */

public class WeekendSalesAdapter extends RecyclerView.Adapter<WeekendSalesAdapter.ViewHolder> {
    private Context context;
    private WeekendSalesDataEntity weekendSalesDataEntity;

    public WeekendSalesAdapter(Context context, WeekendSalesDataEntity weekendSalesDataEntity) {
        this.context = context;
        this.weekendSalesDataEntity = weekendSalesDataEntity;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_weekendsales, null);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.tv_moviename_weekendsales.setText("电影名：" + weekendSalesDataEntity.getShowapi_res_body().getDatalist().get(position).getMovieName());
        holder.tv_days_weekendsales.setText("上映天数：" + weekendSalesDataEntity.getShowapi_res_body().getDatalist().get(position).getMovieDay());
        holder.tv_boxoffice_weekendsales.setText("票房统计：" + weekendSalesDataEntity.getShowapi_res_body().getDatalist().get(position).getBoxOffice());
    }

    @Override
    public int getItemCount() {
        return weekendSalesDataEntity.getShowapi_res_body().getDatalist().size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tv_moviename_weekendsales;// 电影名
        private TextView tv_days_weekendsales;// 上映天数
        private TextView tv_boxoffice_weekendsales;// 票房统计

        public ViewHolder(View itemView) {
            super(itemView);
            tv_moviename_weekendsales = (TextView) itemView.findViewById(R.id.tv_moviename_weekendsales);// 电影名
            tv_days_weekendsales = (TextView) itemView.findViewById(R.id.tv_days_weekendsales);// 上映天数
            tv_boxoffice_weekendsales = (TextView) itemView.findViewById(R.id.tv_boxoffice_weekendsales);// 票房统计
        }
    }
}
